<div class="ibox-content">
    <form id="form" class="form-horizontal m-t" method="post" action="{:\\think\\Url::build('Menu/importMenu',['pid'=>$pid])}">
        <div class="form-group">
            <label class="control-label">说明：<span class="check-tips">(请按照导入格式输入)</span></label>
            <textarea name="tree" class="form-control" rows="4"></textarea>
        </div>
        <div class="form-group">
            格式：标题|url(回车键)<br>
            标题|url
        </div>
        <div class="form-group">
            <button class="btn btn-primary ajax-post" type="submit">提交</button>
        </div>
    </form>
</div>
<script type="text/javascript">
    highlight_subnav("{:\\think\\Url::build('menu/index')}");
    $('.ajax-post').on('click', function () { 
        var url = $('#form').attr('action');
        var query = $('#form').serialize();
        $(this).prop('disabled', true);
        $.post(url,query, function (data) {
            if (data.code == 1) {
                data.url ? alert_msg(data.msg + ',页面即将自动跳转~', 1) : alert_msg(data.msg, 1);
                setTimeout(function () {
                    $(this).prop('disabled', false);
                    if (data.url) {
                        location.href = data.url;
                    } else {
                        location.reload();
                    }
                }, 1500);
            } else {
                alert_msg(data.msg, 0);
                setTimeout(function () {
                    $(this).prop('disabled', false);
                }, 1500);
            }
        });
        return false;
    });

</script>
